package com.liangzhong.model.user
{
	import com.adobe.serialization.json.JSON;
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.NotifierEvent;
	import com.liangzhong.model.AppData;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 *用户详细信息 
	 * @author lxh
	 * 
	 */	
	public class UserDetailInfo extends EventDispatcher
	{
		/**
		 * 用户id
		 */		
		public var uid :int;
		/**
		 *俱乐部id 
		 */		
		public var cid :int;
		/**
		 *用户帐号 
		 */		
		public var username :String; 
		/**
		 *用户昵称 
		 */		
		public var nickname :String; 
		/**
		 *头像 
		 */		
		public var headurl	 :String;
		/**
		 * 普通黄砖
		 */		
		public var qzone_vip			:int;
		/**
		 * 黄钻等级
		 */		
		public var qzone_viplevel 		:int;
		/**
		 * 年费黄钻
		 */		
		public var qzone_yearvip		:int;
		/**
		 *是否已经领取黄钻礼包 
		 * 0 -- 未领取
		 * 1 -- 已领取
		 */		
		private var _is_get_vip		:int;
		/**
		 * 服务器时间
		 */		
		public var serverTime:Number;
		/**
		 * 邮件量 
		 */
		public var mailNum:int;
		/**
		 * 引导信息
		 */		
		public var guideList :Array;
		/**
		 *[{buff:1,date:"2013-04-27 14:29:45"}] 
		 */		
		public var buffList  :Array;
		/**
		 *是否商会vip
		 * 0 -- 不是
		 * 1 --- 是 
		 */		
		public var merchant	  :int ;
		
		public function UserDetailInfo()
		{
			
		}
		/**
		 *解析数据 
		 * @param data
		 * 
		 */		
		public function parse(data :Object):void
		{
			var res :String = String(data);
			var results :Object = JSON.decode(res);
			//Debug.echo("玩家信息++++++++"+results);
			if(results == null)
			{
				return;
			}
			uid 		= results.user.uid;
			username 	= results.user.username;
			nickname 	= results.user.nickname;
			headurl		= results.user.headurl2;
			qzone_vip			= results.user.qzone_vip;
			qzone_viplevel		= results.user.qzone_viplevel;
			qzone_yearvip		= results.user.qzone_yearvip;
			_is_get_vip			= results.user.is_get_vip;
			cid 		= results.cid;
			serverTime 	= results.time.time;
			mailNum		= results.mail;
			guideList 	= results.guide;
			buffList    = results.buff;
			merchant	= results.merchant;
			AppData.getInstance().setClientDate(results.time.time);
		}
		/**
		 *是否黄钻用户 
		 * @return 
		 * 
		 */		
		public function isQzoneVip():Boolean
		{
			return (qzone_vip == 1 || qzone_yearvip == 1);
		}
		/**
		 * 获取vip领取状态
		 * @return 
		 * 
		 */		
		public function get is_get_vip():int
		{
			return _is_get_vip;
		}
		/**
		 * 设置vip领取状态
		 * @param value
		 * 
		 */		
		public function set is_get_vip(value :int):void
		{
			_is_get_vip = value;
			this.dispatchEvent(new Event(Event.CHANGE));
		}
	}
}